//蜂巢
var hiveMap= {
    vector:null,
    source:null,
    modify:null,
    rqVector:null,
    rqSource:null,
    rqInfoSource:null,
    selectPointerMove:null,
    isRqInfo:null,
    layer:null,
    getHiveMap: function (inputData, cStyle, cSize, cMin, cMax, legend, opacity) {
        this.modify = new ol.interaction.Modify({
            source: this.getSource(inputData)
        });
        this.modify.setActive(false);
        map.addInteraction(this.modify);
        var style = function(feature, resolution) {
            if(feature == null){
                return;
            }
            var type = feature.getGeometry().getType();
            var style = feature.getStyle();
            var text = null;
            if (typeof feature.getProperties().text === 'undefined') {
                text = 'none';
            } else {
                var text = feature.getProperties().text
            }
            feature.setStyle(hiveMap.getUnselectedPropertyStyle(type, text, style, feature));
        }
        this.rqVector = new ol.layer.Vector({
            style:style
        });
        this.rqVector.setVisible(false);
        map.addLayer(this.rqVector);
        this.selectPointerMove = new ol.interaction.Select({
            condition: ol.events.condition.pointerMove
        });
        this.selectPointerMove.on('select', function (e) {
            hiveMap.onPointerMove(e);
        });
        map.on('singleclick', function (e) {
            hiveMap.onPointerClick(e);
        });
        map.getView().on('change:resolution', function (e) {
            hiveMap.onResChange(e, inputData.city);
        });
        this.initlayer(inputData.city, cStyle, cSize, cMin, cMax, legend, opacity);

    },
    getSource:function (inputData) {
        $.ajaxSettings.async = false;
        var features = new Array();
        var ep3 = new ol.proj.Projection({
            code: 'EPSG:3857'
        });
        var ep4 = new ol.proj.Projection({
            code: 'EPSG:4326'
        });
        var url = "/map/initMapData";
        $.getJSON(url,inputData, function (data) {
            var result = data.result.mapDataList;
            result.forEach(function (val) {
                var point = ol.proj.transform([val.lng,val.lat],ep4,ep3);
                //var point = [val.lng,val.lat];
                var feature = new ol.Feature({
                    id:val.communityId,
                    geometry: new ol.geom.Point(point)
                })
                features.push(feature);
            })
            hiveMap.source = new ol.source.Vector({
                features:features
            })
            hiveMap.source.set('type','heat',false);
        });
        $("#district option").remove();
        $("#s2id_district span:first").html("行政区");
        var city = $("#city").val()
        $("#district").append("<option value='-1' >行政区</option>")
        if(city=='-1'){
            return
        }
        $.ajax({
            url: "/estate/districtList",
            type: "POST",
            data: {'city': city} ,
            success: function(result){
                for(var i=0; i < result.districtList.length; i++){
                    $("#district").append("<option value=" + result.districtList[i].zoneNumber + ">" + result.districtList[i].name + "</option>")
                }
            }
        });
        return hiveMap.source;
        $.ajaxSettings.async = true;
    },
    getRqSource: function (inputData) {
        var url = '/map/mapCommunityData';
        var source = new ol.source.Vector({
            format: new ol.format.GeoJSON({
                defaultDataProjection: 'EPSG:4326',
                featureProjection: 'EPSG:3857'
            }),
            loader: function (extent, resolution, projection) {
                $.ajax({
                    url: url,
                    type: 'POST',
                    async: true,
                    data:inputData,
                    success: function (data) {
                        var list = data.result.mapDataList;
                        var zoom = map.getView().getZoom();
                        var radius = 1e6 / Math.pow(2, zoom - 3);
                        list.forEach(function (item) {
                            var center = ol.proj.transform([item.lng, item.lat], 'EPSG:4326', 'EPSG:3857');
                            //var center =[item.lng, item.lat];
                            var feature = new ol.Feature({
                                id: item.communityId,
                                geometry: new ol.geom.Circle(center, radius),
                                text: item.communityName.replace(/\s/g, "") + '\n' + item.count + '笔'
                            });
                            feature.set('type', 'rq', false);
                            feature.set('name',item.communityName.replace(/\s/g, ""),false);
                            feature.set('count',item.count,false);
                            source.addFeature(feature);
                        })
                    }
                })
            }
        })
        source.set('type', 'rq', false);
        this.rqSource = source;
        return source;
    },
    getRqInfoSource: function (inputData) {
        var url = '/map/mapBuildingBankData2';
        var source = new ol.source.Vector({
            format: new ol.format.GeoJSON({
                defaultDataProjection: 'EPSG:4326',
                featureProjection: 'EPSG:3857'
            }),
            loader: function (extent, resolution, projection) {
                $.getJSON(url, inputData, function (data) {
                    var divList = hiveMap.createDiv(data.result.mapDataList, inputData);
                    divList.forEach(function (item) {
                        var div = item[0];
                        //var point = ol.proj.transform(item[1], 'EPSG:4326', 'EPSG:3857');
                        var point = item[1];
                        var overly = new ol.Overlay({
                            element: div,
                            position: point,
                            positioning: 'bottom-right',
                            autoPan: true,
                            autoPanAnimation: {
                                duration: 250
                            }
                        })
                        map.addOverlay(overly);
                    })
                })
            }
        })
        source.set('id', 'rqInfo');
        this.rqInfoSource = source;
        return source;
    },
    initlayer:function (city, cStyle, cSize, cMin, cMax, legend, opacity) {
        var hexbin, binSize;
        var style = cStyle;
        var min, max, maxi;
        var styleFn = function (f, res) {
            switch (style.val()) {
                case 'point': {
                    var radius = Math.round(binSize / res + 0.5) * Math.min(1, f.get('features').length / max);
                    return [new ol.style.Style({
                        image: new ol.style.RegularShape({
                            points: 6,
                            radius: radius,
                            fill: new ol.style.Fill({color: [0, 0, 255]}),
                            rotateWithView: true
                        }),
                        geometry: f.get('center')
                    })
                        //, new ol.style.Style({ fill: new ol.style.Fill({color: [0,0,255,.1] }) })
                    ];
                }
                // Display the polygon with a gradient value (opacity)
                // depending on the number of objects in the aggregate.
                case 'gradient': {
                    var opacity = Math.min(1, f.get('features').length / max);
                    return [new ol.style.Style({fill: new ol.style.Fill({color: [0, 0, 255, opacity]})})];
                }
                // Display the polygon with a color
                // depending on the number of objects in the aggregate.
                case 'color':
                default: {
                    var color;
                    if (f.get('features').length > max) color = [136, 0, 0, 1];
                    else if (f.get('features').length > min) color = [255, 165, 0, 1];
                    else color = [0, 136, 0, 1];
                    return [new ol.style.Style({fill: new ol.style.Fill({color: color})})];
                }
            }
        };
        function reset(size) {
            if (hiveMap.layer) {
                map.removeLayer(hiveMap.layer);
            }
            binSize = size;
            var features;
            // An image layer
            hexbin = new ol.source.HexBin({
                source: hiveMap.source,		// source of the bin
                size: size			// hexagon size (in map unit)
            });
            hiveMap.layer = new ol.layer.Vector({source: hexbin, opacity: opacity, style: styleFn});
            features = hexbin.getFeatures();
            // Calculate min/ max value
            min = Infinity;
            max = 0;
            for (var i = 0, f; f = features[i]; i++) {
                var n = f.get('features').length;
                if (n < min) min = n;
                if (n > max) max = n;
            }
            var dl = (max - min);
            maxi = max;
            min = Math.max(1, Math.round(dl / 4));
            max = Math.round(max - dl / 3);
            cMin.text(min);
            cMax.text(max);
            // Add layer
            map.addLayer(hiveMap.layer);
        }
        reset(Number(cSize.val()));
        cSize.off("change").on("change", function () {
            reset(Number(cSize.val()));
        });
        cStyle.off("change").on("change", function () {
            hexbin.changed();
            legend.removeClass().addClass($(this).val())
        });
    },
    onPointerClick:function (e) {
        var pixel = map.getEventPixel(e.originalEvent);
        var feature = map.forEachFeatureAtPixel(pixel, function (feature, layer) {
            return feature;
        });
        if (feature == null){
            return;
        }else{
            var type = feature.getGeometry().getType();
            var ty  = feature.get('type');
            if (type == 'Circle') {
                if(ty == 'rq'){
                    var id = feature.N.id;
                    hiveMap.inputData = this.getInputData('aggregation');
                    hiveMap.inputData.communityId=id;
                    var extent = feature.getGeometry().getExtent();
                    var center = ol.extent.getCenter(extent);
                    hiveMap.rqVector.setSource(hiveMap.getRqInfoSource(hiveMap.inputData))
                    map.getView().animate({
                        center: center,
                        duration: 1
                    });
                    map.getView().setZoom(18);
                    hiveMap.hiddenOverly();
                }
            } else {
                return;
            }
        }
    },
    onPointerMove: function (e) {
        var feature = e.selected[0];
        if (feature == null) {
            if(hiveMap.rqVector.getSource().getFeatures().length > 0) {
                hiveMap.rqVector.getSource().getFeatures().forEach(function (feature) {
                    var type = feature.getGeometry().getType();
                    var text = feature.getProperties().text;
                    var style = feature.getStyle();
                    feature.setStyle(hiveMap.getUnselectedPropertyStyle(type, text, style,feature));
                })
            }
            return;
        } else {
            var type = feature.getGeometry().getType();
            if (type == 'Circle') {
                var text = feature.getProperties().text;
                feature.setStyle(hiveMap.getSelectedPropertyStyle(type, text));
            }
        }
    },
    onResChange: function (e) {
        var zoom = map.getView().getZoom();
        var value = 6000;
        if(zoom>10 && zoom < 16) {
            $('#size').val(value - ((zoom - 10) * 1500));
            $("#size").change();
            hiveMap.rqVector.setVisible(false);
            map.removeInteraction(hiveMap.selectPointerMove);
            hiveMap.hiddenOverly();
        }
        if (zoom < 16) {
            if (!hiveMap.layer.getVisible()) {
                hiveMap.isRqInfo = false;
                // hiveMap.vector.setVisible(true);
                hiveMap.rqVector.setVisible(false);
                map.removeInteraction(hiveMap.selectPointerMove);
                hiveMap.hiddenOverly();

            }
        } else if (zoom >= 16 && zoom < 18) {
            hiveMap.rqVector.setVisible(true);
            hiveMap.layer.setVisible(false);
            if (hiveMap.rqSource != null) {
                hiveMap.rqVector.setSource(hiveMap.rqSource)
            } else {
                hiveMap.rqVector.setSource(hiveMap.getRqSource(hiveMap.inputData))
            }
            hiveMap.hiddenOverly();
            map.addInteraction(hiveMap.selectPointerMove);
            hiveMap.setCircle(zoom);
        } else if (zoom >= 18) {
            hiveMap.layer.setVisible(false);
            hiveMap.rqVector.setVisible(true);
            hiveMap.rqVector.setSource(hiveMap.rqInfoSource)
            map.addInteraction(hiveMap.selectPointerMove);
            hiveMap.setCircle(zoom);
            hiveMap.showOverly();
        }

    },
    setCircle: function (zoom) {
        if(this.rqVector.getSource() != null) {
            this.rqVector.getSource().forEachFeature(function (feature) {
                var geo = feature.getGeometry();
                if (geo.getType() == 'Circle') {
                    geo.setRadius(1e6 / Math.pow(2, zoom - 3));
                }
            })
        }
    },
    getSelectedPropertyStyle: function (type, text) {
         var style = null;
         if (type == 'Circle') {
             style = new ol.style.Style({
                 fill: new ol.style.Fill({
                     color: 'rgba(226, 74, 76, 1)',
                     opacity: '0.05'
                 }),
                 text: new ol.style.Text({
                     font: '10px',
                     textAlign: 'center',
                     rotateWithView: true,
                     text: text,
                     fill: new ol.style.Fill({
                         color: '#FFFFFF'
                     })
                 })
             })
         }
         if (type == 'MultiPolygon' || type == 'Polygon') {
             style = new ol.style.Style({
                 stroke: new ol.style.Stroke({
                     color: 'green',
                     width: 2
                 }),
                 fill: new ol.style.Fill({
                     color: 'rgba(76, 160, 101, 0.5)'
                 })
             })
         }
         return style;
     },
    getUnselectedPropertyStyle: function (type, text, Style,feat) {
         var style = null;
         var style = null;
         if (type == 'Point') { // 如果是点, 不去设置他的样式
             style = Style;
         }
         if (type == 'Circle') {
             var id =  'rq';
             var size =feat.get('count');
             var color = hiveMap.getColorForId(id,size);
             style = new ol.style.Style({
                 fill: new ol.style.Fill({
                     color:color,
                     opacity: '0.05'
                 }),
                 text: new ol.style.Text({
                     font: '10px',
                     textAlign: 'center',
                     rotateWithView: true,
                     text: text,
                     fill: new ol.style.Fill({
                         color: 'rgba(255, 255, 255, 1)'
                     })
                 })
             })
         }
         // if (type == 'MultiPolygon' || type == 'Polygon') {
         //     style = new ol.style.Style({
         //         stroke: new ol.style.Stroke({
         //             color: 'rgba(55, 155, 205, 1)',
         //             width: 1
         //         })
         //     })
         // }
         return style;
     },
    getCenter: function (inputData) {
        var id = null;
        if(inputData.length==6){
           id = inputData
        }else{
            id = inputData.city
        }
        var cityId = id.substring(0, 2);
        var center = null;
        var url = '../../assets/newMap/data/mapdata/city/' + cityId + '.json';
        $.ajax({
            url: url,
            type: 'GET',
            async: false,
            success: function (data) {
                data.features.forEach(function (item) {
                    if (id == (item.properties.id + '00')) {
                        center = ol.proj.transform(item.properties.cp, 'EPSG:4326', 'EPSG:3857');
                        return;
                    }
                });
                if(center == null){
                    center = ol.proj.transform(data.cp, 'EPSG:4326', 'EPSG:3857');
                }
            }
        })
        return center;
    },
    reset:function (city, cStyle, cSize, cMin, cMax, legend, opacity) {
        var cSize = $("#size");
        var cStyle = $("#style");
        var cMax = $(".max");
        var cMin = $(".min");
        var legend = $('#legend');
        var opacity = 0.5;
        if(this.layer != null) {
            map.removeLayer(this.layer)
        }
        // if(this.vector != null){
        //     map.removeLayer(this.vector)
        // }
        if(this.rqVector != null) {
            map.removeLayer(this.rqVector)
        }
        if(this.modify != null){
            map.removeInteraction(this.modify)
        }

        this.getHiveMap(city, cStyle, cSize, cMin, cMax, legend, opacity);
        var center = null;
        var zoom = 10;
        if (city.city == '330100') {
            center = ol.proj.transform([120.1551500000, 30.2741500000], 'EPSG:4326', 'EPSG:3857');
            //center = [120.1551500000, 30.2741500000];
        } else if(inputData.city == '530100') {
            center = [11448432.348440556, 2861190.842770717];
        } else {
            center = this.getCenter(city);
        }
        map.getView().setCenter(center);
    },
    setRqCenter:function (community,inputData) {
        //var center = ol.proj.transform([community.lng, community.lat], 'EPSG:4326', 'EPSG:3857');
        var center = [community.lng, community.lat];
        this.inputData = inputData;
        this.rqInfoSource = this.getRqInfoSource(inputData);
        hiveMap.layer.setVisible(false);
        //hiveMap.vector.setVisible(false);
        hiveMap.rqVector.setVisible(true);
        hiveMap.isRqInfo = true;
        hiveMap.rqVector.setSource(this.rqInfoSource);
        map.getView().setCenter(center);
        map.getView().setZoom(18);
        map.getOverlays().clear();
    },
    getInputData: function(currentMap) {
        var communityName = $("#search").val(),
            city = $('#city').val(),
            district = $('#district').val(),
            risk = $('#risk').val(),
            startDateStart = $('#startDateStart').val(),
            startDateEnd = $('#startDateEnd').val(),
            buildArea = $('#buildArea').val(),
            customCode = $('#customCode').val(),
            customValue = $('#customValue').val(),
            loansDuration = $('#loansDuration').val(),
            inputData = {
                communityName: communityName,
                city: city,
                district: district,
                risk: risk,
                startDateStart: startDateStart,
                startDateEnd: startDateEnd,
                buildArea: buildArea,
                loansDuration: loansDuration,
                currentMap: currentMap,
                customCode: customCode,
                customValue: customValue,
            };
        return inputData;
    },//楼栋覆盖物
    createDiv:function(paramsData,inputData) {
        var resultList = new Array();
        var tmpList = new Array();
        var resultList, topDiv, sj, lastSmall, oneSmall;
        paramsData.forEach(function (searchEstate) {
            var div = document.createElement("div");
            searchEstate.forEach(function (data, i) {
                //自定义楼栋覆盖物
                var smallDiv;
                if (i != 0) {
                    if (oneSmall) oneSmall.style.padding = "0 10px 0 5px";
                    smallDiv = document.createElement('div');
                    smallDiv.appendChild(document.createTextNode(data.estateList.length + '笔'));
                    smallDiv.style.padding = "0 10px 0 10px";
                    smallDiv.style.borderRadius = '8px';
                    smallDiv.style.marginLeft = '-10px';
                    smallDiv.style.lineHeight = '25px';
                    if (data.estateList[0].define == '中风险') {
                        smallDiv.style.backgroundColor = "#FF9800";
                    } else if (data.estateList[0].define == '低风险') {
                        smallDiv.style.backgroundColor = "#62CB31";
                    } else if (data.estateList[0].define == '高风险') {
                        smallDiv.style.backgroundColor = "#E51C23";
                    } else if (data.estateList[0].define == '亏损') {
                        smallDiv.style.backgroundColor = "#8B1818";
                    }
                    lastSmall = smallDiv;
                    topDiv.appendChild(smallDiv);
                } else {
                    if (lastSmall) lastSmall.style.padding = '0 10px';

                    div.style.position = "absolute";
                    div.style.color = "white";
                    div.style.opacity = '0.95';
                    div.style.display = 'flex';
                    div.style.whiteSpace = "nowrap";
                    div.style.MozUserSelect = "none";
                    div.style.fontSize = "12px";
                    div.style.cursor = "pointer";
                    div.style.height = "25px";
                    smallDiv = document.createElement('div');
                    smallDiv.appendChild(document.createTextNode(data.estateList.length + '笔'));
                    smallDiv.style.padding = "0 10px 0 5px";
                    smallDiv.style.borderRadius = "8px";
                    smallDiv.style.lineHeight = "25px";
                    div.appendChild(smallDiv);
                    sj = this._p = document.createElement("p");
                    if (data.estateList[0].define == '中风险') {
                        smallDiv.style.backgroundColor = "#FF9800";
                        sj.style.borderTop = "10px solid #FF9800";
                    } else if (data.estateList[0].define == '低风险') {
                        smallDiv.style.backgroundColor = "#62CB31";
                        sj.style.borderTop = "10px solid #62CB31";
                    } else if (data.estateList[0].define == '高风险') {
                        smallDiv.style.backgroundColor = "#E51C23";
                        sj.style.borderTop = "10px solid #E51C23";
                    } else if (data.estateList[0].define == '亏损') {
                        smallDiv.style.backgroundColor = "#8B1818";
                        sj.style.borderTop = "10px solid #8B1818";
                    }
                    sj.style.position = "absolute";
                    sj.style.width = 0;
                    sj.style.height = 0;
                    sj.style.borderLeft = "10px solid transparent";
                    sj.style.borderRight = "10px solid transparent";
                    sj.style.bottom = "-20px";
                    sj.style.left = '6px';
                    div.appendChild(sj);
                    oneSmall = smallDiv;
                    lastSmall = null;
                    topDiv = div;
                }
                $(topDiv).hover(function () {
                    $(this).css('z-index',11);
                },function () {
                    $(this).css('z-index','auto')
                });
                topDiv.onclick = function () {
                    $(this).parent().siblings().children().children("div.row").css("display", "none");
                    $(this).parent().siblings().children().css('zIndex', 'auto');
                    $(this).css('zIndex', '11')
                    $(this).children('div.row').toggle();
                    if ($(this).children('div.row').length >= 1) return;
                    var listDiv = document.createElement("div");
                    listDiv.style.position = 'absolute';
                    listDiv.style.left = this.offsetWidth + 14 + "px";
                    listDiv.style.color = '#6a6c6f';
                    listDiv.style.width = '400px';
                    listDiv.style.whiteSpace = 'normal';
                    listDiv.className = 'row';
                    var col = document.createElement("div");
                    var hpanel = document.createElement("div");
                    hpanel.className = 'hpanel';
                    var hpanelHead = document.createElement("div");
                    hpanelHead.className = 'panel-heading hbuilt';
                    hpanelHead.onclick = function (e) {
                        e.stopPropagation();
                    };
                    var panelTools = document.createElement('div');
                    panelTools.className = 'panel-tools';
                    var closebox = document.createElement('a');
                    var closeIcon = document.createElement('i');
                    closeIcon.className = 'fa fa-times';
                    closebox.appendChild(closeIcon);
                    closebox.className = 'closebox';
                    var that = $(this);
                    closebox.onclick = function () {
                        that.children("div.row").css("display", "none");
                    };
                    panelTools.appendChild(closebox);
                    hpanelHead.appendChild(panelTools);
                    var aHref = document.createElement('a');
                    aHref.appendChild(document.createTextNode(data.estateList[0].communityname));
                    aHref.setAttribute('href',location.origin + '/estate/index?communityId=' + inputData.communityId);
                    hpanelHead.appendChild(aHref);
                    var hpanelBody = document.createElement("div");
                    hpanelBody.className = 'panel-body no-padding';
                    hpanelBody.style.maxHeight = '190px';
                    hpanelBody.style.overflowY = 'auto';
                    var listGroup = document.createElement('ul');
                    listGroup.className = 'list-group';
                    var hpanelFoot = document.createElement('div');
                    hpanelFoot.className = 'panel-footer';
                    hpanelBody.appendChild(listGroup);
                    hpanel.appendChild(hpanelHead);
                    hpanel.appendChild(hpanelBody);
                    hpanel.appendChild(hpanelFoot);
                    col.appendChild(hpanel);
                    listDiv.appendChild(col);
                    this.appendChild(listDiv);
                    searchEstate.forEach(function (data) {
                        var itemData = data.estateList;
                        itemData.forEach(function (data) {
                            var item = document.createElement('li');
                            item.className = 'list-group-item ';
                            var badge = document.createElement('span');
                            badge.className = 'badge badge-info';
                            badge.innerHTML = data.cltv + '%';
                            item.appendChild(badge);
                            if (data.define == '中风险') {
                                badge.style.backgroundColor = "#FF9800";
                            } else if (data.define == '低风险') {
                                badge.style.backgroundColor = "#62CB31";
                            } else if (data.define == '高风险') {
                                badge.style.backgroundColor = "#E51C23";
                            } else if (data.define == '亏损') {
                                badge.style.backgroundColor = "#8B1818";
                            }
                            item.appendChild(document.createTextNode(data.sourceaddress));
                            item.onclick = function () {
                                var href = window.location.origin + "/estate/mapShow/" + data.id;
                                window.open(href);
                            };
                            listGroup.appendChild(item);
                        });
                    });
                    var listLength = listGroup.children.length;
                    hpanelFoot.innerHTML = '共 ' + listLength + ' 笔';
                };
            });
            tmpList = new Array();
            tmpList[0] = topDiv;
            tmpList[1] =[searchEstate[0].lng,searchEstate[0].lat];
            resultList.push(tmpList);
        });
        return resultList;
    },
    hiddenOverly:function () {
        var eleOverlys = $('.ol-overlay-container.ol-selectable');
        for(var i=0;i<eleOverlys.length;i++){
            var div = eleOverlys[i];
            var dis = div.style.display;
            if(dis != 'none'){
                div.style.display = 'none';
            }
        }
    },
    showOverly:function () {
        var eleOverlys = $('.ol-overlay-container.ol-selectable');
        for(var i=0;i<eleOverlys.length;i++){
            var div = eleOverlys[i];
            var dis = div.style.display;
            if(dis != 'block'){
                div.style.display = 'block';
            }
        }
    },
    getColorForId: function (id,size) {
        var color = 'rgba(76, 160, 101, 0.9)';
        switch (id) {
            case 'province': {
                color = 'rgba(76, 160, 101, 0.9)';
            }
                break;
            case 'city': {
                if (size > 700) {
                    color = "#26b095";
                } else if (size > 500) {
                    color = "#33c3a7"
                } else if (size > 300) {
                    color = "#4cdcc0";
                } else {
                    color = "#79ecd6";
                }
            }
                break;
            case 'county': {
                if (size > 700) {
                    color = "#26b095";
                } else if (size > 500) {
                    color = "#33c3a7"
                } else if (size > 300) {
                    color = "#4cdcc0";
                } else {
                    color = "#79ecd6";
                }
            }
                break;
            case 'rq': {
                if (size > 15) {
                    color = "#26b095";
                } else if (size > 10) {
                    color = "#33c3a7"
                } else if (size > 5) {
                    color = "#4cdcc0";
                } else {
                    color = "#79ecd6";
                }
            }
                break;
        }
        return color;
    }
}